/***
 * create by zm
 * 2020/03/17
 *
 * ***/
import Vue from 'vue';
import wx from 'weixin-js-sdk';
import axios from 'axios';
export default {
  wxShareAdd: function(title, desc, link, img, type, callBack) {
    wx.ready(function() {
      wx.showOptionMenu();
      wx.showMenuItems({
        menuList: ['menuItem:share:appMessage', 'menuItem:share:timeline', 'menuItem:share:wechat'],
      });
      wx.onMenuShareTimeline({
        title: title,
        link: link,
        imgUrl: img,
        success: function() {
          if (success) {
            callBack();
          }
        },
        cancel: function() {},
      });
      wx.onMenuShareAppMessage({
        title: title,
        desc: desc,
        link: link,
        imgUrl: img,
        success: function() {
          callBack();
        },
        cancel: function() {},
      });
      wx.onMenuShareWechat({
        title: title,
        desc: desc,
        link: link,
        imgUrl: img,
        success: function() {
          callBack();
        },
        cancel: function() {},
      });
    });
  },
  wxShareHide: function() {
    if (wx) {
      wx.hideOptionMenu();
      wx.hideMenuItems({
        menuList: [
          'menuItem:refresh',
          'menuItem:share:appMessage',
          'menuItem:share:timeline',
          'menuItem:share:qq',
          'menuItem:share:weiboApp',
          'menuItem:share:facebook',
          'menuItem:share:QZone',
        ], // 禁止用户刷新
      });
    }
  },
};
